/* Copyright (c) 2010, David Kreuter. See LICENSE for more information */

#include "headers.h"

trx *read_trx(uint8 *buf, uint32 len){
	START(read_trx);
	trx *r=(trx*)malloc(sizeof(trx));

	r->w=buf[0];
	r->h=buf[1];
	memcpy(r->name,buf+5,buf[4]);
	r->name[buf[4]]=0;

	r->data=malloc(r->w*r->h*2);
	memcpy(r->data,buf+5+buf[4],r->w*r->h*2);

	END(read_trx,r);
}

int write_trx(trx *r, uint8 *buf, uint32 len){
	START(write_trx);
	END(write_trx,1);
}

void free_trx(trx *r){
	START(free_trx);
	if(r)free(r);
	ENDV(free_trx);
}

uint32 size_trx(trx *r){
	START(size_trx);
	END(size_trx,0);
}
